package com.shop.utils;

import io.swagger.models.auth.In;
import lombok.Data;

@Data
public class PageUtils {
    //当前页数
    private  Integer current;
    //每页显示几条数据
    private Integer size;
    //总共页数
    private  Integer pageSize;
    //存放数据
    private Object data;
    //所有的数据
    private Integer count;

    public static ResultUtils  pageInfo(Object data,Integer count,Integer current,Integer size){
        boolean empty = StringEmptyUtils.isEmpty(data);
        if(!empty){
            return  ResultUtils.error(500,"查询数据不能为空");
        }
        if(count==0){
            return  ResultUtils.error(500,"查询记录数等于0");
        }
        PageUtils pageUtils=new PageUtils();
        pageUtils.setPageSize(count%size==0?count/size:count/size+1);
        pageUtils.setData(data);
        pageUtils.setSize(size);
        pageUtils.setCurrent(current);
        pageUtils.setCount(count);
        return ResultUtils.ok(pageUtils);
    }

}
